package com.lnking.lnkingplace.controller;


import com.lnking.common.http.ReturnResult;
import com.lnking.lnkingplace.model.login.LoginCompareRequest;
import com.lnking.lnkingplace.model.login.LoginRequest;
import com.lnking.lnkingplace.model.login.PasswordRequest;
import com.lnking.lnkingplace.model.login.SmsLoginRequest;
import com.lnking.lnkingplace.model.request.user.UserSearchRequest;
import com.lnking.lnkingplace.service.ILoginService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author zxq
 * @since 2022-08-18
 */
@Api(tags = "登录模块")
@RestController
public class LoginController {

    @Autowired
    ILoginService loginService;

    @PostMapping("/login")
    public ReturnResult login(@RequestBody @Valid LoginRequest params) throws Exception {
        return loginService.login(params);
    }




    @ApiOperation("短信登录")
    @PostMapping("/sms/login")
    public ReturnResult smsLogin(@RequestBody @Valid SmsLoginRequest params) {
        return loginService.smsLogin(params);
    }

    @ApiOperation("手机号验证")
    @PostMapping("/sms/phone")
    public ReturnResult smsPhone(@RequestBody @Valid SmsLoginRequest params) {
        return ReturnResult.success(loginService.smsPhone(params));
    }


    @ApiOperation("重置密码")
    @PostMapping("/set/password")
    public ReturnResult setPassword(@RequestBody @Valid PasswordRequest params) {
        loginService.setPassword(params);
        return ReturnResult.success();
    }

    @ApiOperation("登录验证")
    @PostMapping("/register")
    public ReturnResult compare(@RequestBody  @Valid LoginCompareRequest params) {
        loginService.find(params);
        return ReturnResult.success();
    }

}
